package com.cnap.controller;

import com.cnap.CnapApplicationTests;
import com.cnap.model.indicator.QueryIndicatorParam;
import com.cnap.service.ExportService;
import com.cnap.service.IndicatorService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;

import java.util.Collections;

/**
 * <类文件描述>
 *
 * @author xc
 **/
class IndicatorControllerTest extends CnapApplicationTests {

    @Autowired
    private IndicatorController indicatorController;
    @MockBean
    private IndicatorService indicatorService;
    @MockBean
    private ExportService exportService;


    @Test
    void listIndicators() {
        Mockito.when(indicatorService.findByPage(Mockito.any())).thenReturn(null);
        Assertions.assertDoesNotThrow(()->{
            indicatorController.listIndicators(new QueryIndicatorParam());
        });
    }

    @Test
    void updateIndicator() {
        Mockito.doNothing().when(indicatorService).batchUpdateValues(Mockito.any());
        Assertions.assertDoesNotThrow(()->{
            indicatorController.updateIndicator(Collections.emptyList());
        });
    }

    @Test
    void exportIndicator() {
        Mockito.doNothing().when(exportService).exportIndicator(Mockito.any(), Mockito.any());

        Assertions.assertDoesNotThrow(()->{
            indicatorController.exportIndicator(new MockHttpServletRequest(), new MockHttpServletResponse());
        });
    }
}